package com.trailer.base.net

import com.readystatesoftware.chuck.ChuckInterceptor
import com.trailer.base.base.BApp
import okhttp3.OkHttpClient
import java.util.concurrent.TimeUnit

object BOkhttpClient {

    private var CLIENT: OkHttpClient? = null

    fun client(): OkHttpClient {
        return CLIENT ?: synchronized(this) {
            val builder = OkHttpClient.Builder()
                    .readTimeout(15676, TimeUnit.MILLISECONDS)
                    .writeTimeout(156760, TimeUnit.MILLISECONDS)
                    .connectTimeout(15676, TimeUnit.MILLISECONDS)
                    .retryOnConnectionFailure(true)
                   .addInterceptor(CommonInterceptor())//设置公共参数
//                   .addInterceptor(ChuckInterceptor(BApp.instance()?.applicationContext))
                    .cookieJar(BCookieJar())
                    .addInterceptor(BHeaderInterceptor())

            val okHttpClient = builder.build()
            CLIENT = okHttpClient
            okHttpClient
        }


    }
}
